home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 4.2 KB | 184 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEventU.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- #ifndef SLMIXOS_H
- #include "SLMixOS.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__EVENTS__)
- #include <Events.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <windows.h>
- #endif
-
- #pragma segment fwevents
-
- //----------------------------------------------------------------------------------------
- // ::FW_IsKeyPressed
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_IsKeyPressed(unsigned short theKey)
- {
- #ifdef FW_BUILD_MAC
- KeyMap theKeyMap;
- ::GetKeys(theKeyMap);
- const unsigned char *theKeys = (const unsigned char *) theKeyMap;
- return ((theKeys[theKey >> 3] >> (theKey & 7)) & 1);
- #endif
-
- #ifdef FW_BUILD_WIN
- return ((::GetKeyState(theKey) & 0x8000) != 0);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_GetMouseLocation
- //----------------------------------------------------------------------------------------
- // return value in frame coordinate
-
- FW_CPoint FW_GetMouseLocation(Environment* ev, ODFacet* facet)
- {
- FW_CPlatformPoint windowLoc;
-
- ODWindow* window = facet->GetWindow(ev);
- ODPlatformWindow plfmWindow = window->GetPlatformWindow(ev);
-
- #ifdef FW_BUILD_MAC
- GrafPtr curPort;
- ::GetPort(&curPort);
- ::SetPort(plfmWindow);
- ::GetMouse(&windowLoc);
- ::SetPort(curPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- ::GetCursorPos(&windowLoc);
- ::ScreenToClient(plfmWindow, &windowLoc);
- #endif
-
- FW_CPoint point(windowLoc);
- FW_WindowToFrame(ev, facet, point);
-
- return point;
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_GetMouseLocation
- //----------------------------------------------------------------------------------------
- // return value in content coordinate
-
- FW_CPoint FW_GetMouseLocation(ODWindow* theODWindow, FW_CGraphicContext& theGC)
- {
- FW_CPlatformPoint plformLoc;
-
- #ifdef FW_BUILD_MAC
- FW_UNUSED(theODWindow);
- ::GetMouse(&plformLoc);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_SOMEnvironment ev;
- ::GetCursorPos(&plformLoc);
- ODPlatformWindow plfmWindow = theODWindow->GetPlatformWindow(ev);
- ::ScreenToClient(plfmWindow, &plformLoc);
- #endif
-
- return theGC.DeviceToLogical(plformLoc);
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_WaitMouseUp
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_WaitMouseUp()
- {
- #ifdef FW_BUILD_MAC
- return ::StillDown(); //::WaitMouseUp();
- #endif
- #ifdef FW_BUILD_WIN
- MSG event;
- if (::PeekMessage(&event, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE))
- {
- return event.message != WM_LBUTTONUP &&
- event.message != WM_RBUTTONUP &&
- event.message != WM_LBUTTONDOWN &&
- event.message != WM_RBUTTONDOWN;
- }
- return TRUE;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_WaitFor
- //----------------------------------------------------------------------------------------
-
- void FW_WaitFor(long tickCount)
- {
- long targetTick = ::FW_GetTickCount() + tickCount;
- while (::FW_GetTickCount() <= targetTick) {}
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_ForceAdjustCursor
- //----------------------------------------------------------------------------------------
-
- void FW_ForceAdjustCursor(Environment *ev)
- {
- FW_CSession::GetDispatcher(ev)->InvalidateFacetUnderMouse(ev);
- }
-
-